<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="table-scrollable">
	<table class="table table-striped table-hover table-success">
		<thead>
			<tr>
				<th>#</th>
				<th>姓名</th>
				<th>手机号</th>
				<th>是否有PDA</th>
				<th>是否作废</th>
				<th>取派标准</th>
				<th>所谓单位</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.result }" var="staff" varStatus="vs">
			<tr>
				<td>${vs.count + (page.pageNo - 1) * page.pageSize}</td>
				<td>${staff.name}</td>
				<td>${staff.telephone}</td>
				<td>${staff.haspda.equals("1") ? "是" : "否"}</td>
				<td>${staff.deltag.equals("0") ? "正常使用" : "已作废"}</td>
				<td>${staff.standard}</td>
				<td>${staff.station}</td>
				<td>
					<a href="javascript:;" class="btn btn-sm blue" onclick="update('/staff/staff?id=${staff.id}')">
						<i class="fa fa-edit"></i>编辑
					</a>
					<span id="deltag_${staff.id }">
						<c:if test="${staff.deltag.equals('0') }">
							<a href="javascript:;" class="btn btn-sm red" onclick="operation(this,'${staff.id}','1')">
								<i class="fa fa-trash"></i>
								作废
							</a>
						</c:if>
						
						<c:if test="${staff.deltag.equals('1') }">
							<a href="javascript:;" class="btn btn-sm green" onclick="operation(this,'${staff.id}','0')">
								<i class="fa fa-undo"></i>
								还原
							</a>
						</c:if>
					</span>
				</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<div class="pageination-panel">${page}</div>
<script type="text/javascript">
/**
 * 作废或还原取派员
 */
function operation(obj, staffId, deltag){
	
	var url = webRoot + "/staff/updateDelTag";
	var data = {"id":staffId, "deltag":deltag};
	$.post(url, data, function(result){
		if(result.code == 0) {
			if(deltag == "0") {
				$("#deltag_"+staffId).parent().parent().find("td:eq(4)").html("正常使用");
				$("#deltag_"+staffId).html("<a href=\"javascript:;\" class=\"btn btn-sm red\" " +
						" onclick=\"operation(this,'"+ staffId +"','1')\"><i class=\"fa fa-trash\"></i> 作废" );
			}else{
				$("#deltag_"+staffId).parent().parent().find("td:eq(4)").html("已作废");
				$("#deltag_"+staffId).html("<a href=\"javascript:;\" class=\"btn btn-sm green\" " +
				" onclick=\"operation(this,'"+ staffId +"','0')\"><i class=\"fa fa-undo\"></i> 还原" );
			}
			layer.msg(result.message, {shift: 1});
		}else {
			layer.msg(result.message, {shift: 1});
		}
	})
}
</script>